package runnable;

import guiobj.JobPanelController;
import guiobj.SubmitPanelInfo;

import java.io.File;

import data.JobData;

import utils.SSHUtils;
import utils.Utils;

public class GetFiles implements Runnable  {
	String jobname;
	
	public GetFiles(String j)
	{
		this.jobname = j;
	}
	
	public void run()
	{
		SubmitPanelInfo i = Utils.jobs.get(jobname);
		File targetDir = new File(i.resdir);

		/*if(!isSire)
		{
		if(!SSHUtils.ScpFrom(i.resdir+File.separator+jobname+".out","~/"+jobname+"/"+jobname+".out"))
		{
			Utils.out("Error retreving file");
			return;
		}
		}
		else
		{*/
			String fname = jobname+"_results.zip";
			if(!SSHUtils.ScpFrom(i.resdir+File.separator+fname,"~/"+jobname+"/"+fname))
			{
				Utils.out("Error retreiving file");
				return;
			}
			/*Utils.unzip(i.resdir+File.separator+fname);
			new File(i.resdir+File.separator+fname).delete();*/
		//}
		Utils.out("JOB "+jobname+" is now terminated!");
		JobPanelController.updateJobStatus(Utils.p, jobname, "Terminated");
	}
}
